package com.xiaobai.shardingsphere.controller;

import com.xiaobai.shardingsphere.entity.OrderVO;
import com.xiaobai.shardingsphere.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderMapper orderMapper;

    @RequestMapping("/insert")
    public Long insert(OrderVO orderVO) {
        orderVO.setCount(1);
        orderVO.setUserId(1L);
        orderVO.setProductName("产品11");
        return orderMapper.insert(orderVO);
    }

    @RequestMapping("/findOrderByIds")
    public List<Map<String, Object>> findOrderByIds(List<Long> orderIds) {
        return orderMapper.findOrderByIds(orderIds);
    }

    @RequestMapping("/list")
    public List<Map<String, Object>> list() {
        return orderMapper.list();
    }
}
